package com.linkstec.redis;

import java.util.HashMap;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import redis.clients.jedis.Jedis;

public class RedisUtilApp {

	private static final Logger logger = LogManager.getLogger();

	//redis-5.0.4
//	private static String hostAndPort = "192.168.2.178:6379";
	private static String hostAndPort = "localhost:6379";
	private static String keyNameSpace = "SMOT_";
	private static String passwd = "foobared";



	public static void main(String[] args) {
		
		try {
			logger.info("开始!!!");
			Map<String, String> cfg = new HashMap<String, String>();
			cfg.put("redisHostAndPortSingle", hostAndPort);
			cfg.put("keyNamespace", keyNameSpace);
			cfg.put("passwd", passwd);
			RedisUtil.setConfig(cfg);
			
			String bbb = RedisUtil.srandmember("testSet");
			if (bbb == null){
				logger.info("bbb为空");
			}
			logger.info(bbb);

		} catch (Exception e) {
			e.printStackTrace();
		}
		logger.info("BitMap+++就是一个string+++++++++++++++++++++++++++++++++++++++++++++++++");
		Jedis jedis = RedisUtil.getJedis();
		/*jedis.setbit("online", 123, true);
		jedis.setbit("online", 222, true);
		jedis.setbit("online", 111, false);*/
		Boolean getbit = jedis.getbit("online", 111);
		if (getbit) {
			logger.info("getbit+++online+++111为真");
		} else {
			logger.info("getbit+++online+++111为假");
		}
		Boolean getbitResult = jedis.getbit("online", 123);
		if (getbitResult){
			logger.info("getbitResult123为1");
		} else {
			logger.info("getbitResult123为0");
		}
		Long bitcountResult = jedis.bitcount("online");
		logger.info("bitcountResult是:" + bitcountResult);
		
		logger.info("HyperLogLog+++就是一个string+++++++++++++++++++++++++++++++++++++++++++++++++");
		/*Long pfaddResult = jedis.pfadd("databases", "Redis", "MongoDB", "MySQL");
		logger.info("pfaddResult是:" + pfaddResult);
		Long pfaddResult2 = jedis.pfadd("databases", "Redis");
		logger.info("pfaddResult2是:" + pfaddResult2);
		Long pfcountResult = jedis.pfcount("databases");
		logger.info("pfcountResult是:" + pfcountResult);*/
		logger.info("++++++geo是++++++zset++++++++++++++++++++++++++++++++++++++++");
		logger.info("++++++++++++++++++++++++++++++++++++++++++++++++++++");
	}
}
